King Ferdinand is comparing the size of his kingdom to neighboring lords, and wants an accurate estimate of how large his kingdom actually is. Please help King Ferdinand determine the area of his land knowing the current floor plan of the kingdom.
The layout of Ferdinand's kingdom is delineated by two types of characters. Castle boundaries are delineated by 'X' and all other type of area is demarcated by a '.'. The area of the kingdom is defined as the integer value of the number of lattice points within the kingdom; that is, the number of dots within the region completely bounded by X's.
The layout of Ferdinand's kingdom is delineated by two types of characters. Castle boundaries are delineated by 'X' and all other type of area is demarcated by a '.'. The area of the kingdom is defined as the integer value of the number of lattice points within the kingdom; that is, the number of dots within the region completely bounded by X's.
Input Format
Line 1: M and N, the boundaries of the castle layoutLines 2...M+1: A line of N characters describing a row of the castle layout
Sample Input
9 19
...................
......XXX.XXX......
......X.X.X.X......
..XXX.X.X.X.X.XXX..
..X.XXX.XXX.XXX.X..
..X.............X..
..X.............X..
..XXXXXXXXXXXXXXX..
...................
Output Format Line 1: Print the size of Ferdinand's kingdom.
Sample Output
34
You must be logged in to submit a solution.